[SYSTEMDS-3955] Add signed SSL certificates support - #2569
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2569 +/- ##
============================================
- Coverage 71.60% 71.45% -0.15%
- Complexity 50259 50413 +154
============================================
Files 1623 1629 +6
Lines 194314 195334 +1020
Branches 37965 38075 +110
============================================
+ Hits 139130 139576 +446
- Misses 44277 44831 +554
- Partials 10907 10927 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ywcb00
left a comment
There was a problem hiding this comment.
Thank you very much for this PR @gaturchenko. :)
Here a few general comments / questions for my understanding:
- Please do not include the key password in the XML config file. Instead, use an environment variable for the key password to avoid leaking this secret when publishing the configuration.
- Regarding the configurable hostname verification: In which case do we not want to check whether the hostname matches the certificate? Should we remove this configuration to make the hostname verification mandatory whenever ssl is enabled?
All the best,
David
| } | ||
|
|
||
| public void setPromise(Promise<FederatedResponse> prom) { | ||
| public synchronized void setPromise(Promise<FederatedResponse> prom) { |
There was a problem hiding this comment.
Use synchronized{ } blocks to mark specific critical sections of the code instead of declaring the whole method as 'synchronized'.
Hey @ywcb00, thanks for the review. Regarding the first point, implemented the change as suggested. About the second, I think the only case is SSH port forwarding, but I think we can remove this option, which I did. Let me know if you have any further comments. |
ywcb00
left a comment
There was a problem hiding this comment.
Thank you very much @gaturchenko. :)
I left again some minor comments in the code, could you please have a look? Other than that, the PR looks good to me.
All the best, David
PS: Please do not overwrite the past commits. Instead, just append a new commit to the PR with the changes. This allows for reviewers to only review the new commits instead of reviewing all changes again. Thanks.
| <sysds.federated.ssl.cert>/path/to/worker-cert.pem</sysds.federated.ssl.cert> | ||
| <sysds.federated.ssl.key>/path/to/worker-key.pem</sysds.federated.ssl.key> | ||
| <sysds.federated.ssl.trust>/path/to/ca-cert.pem</sysds.federated.ssl.trust> |
There was a problem hiding this comment.
Since these configurations are required when ssl is enabled, I would include the configurations in this xml file. I see the point that we do not have any certificates for the corresponding tutorial yet, leaving us with three options to resolve this issue:
- Generate respective certificates for the tutorial and include them in the repository.
- Include the configurations with the current placeholder value (path/to/...) and ensure that, when executing the tutorial with ssl, it is clear from the error messages that these certificates are missing.
- Remove the 'ssl' option from
scripts/tutorials/federated/parameters.sh.
I think the first option would be the best, and the second option fits the scope of this PR best.
| // The promise is assigned by the requesting thread, while the channel events below are handled on the | ||
| // event loop, and the two orders are not guaranteed: a rejected SSL handshake already fails the channel | ||
| // while the requesting thread is still connecting. | ||
| private final Object _promLock = new Object(); |
There was a problem hiding this comment.
Is there a specific reason for creating an object for locking the member variable _prom? I think that we can just use the intrinsic lock from the member variable _prom directly, and thus synchronize on _prom instead of _promLock.
There was a problem hiding this comment.
Done (can't lock on _prom but can lock on the class itself via this)
|
|
||
| try { | ||
| context = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); | ||
| LOG.info("Federated SSL trusting certificates in: " + trustPath); |
There was a problem hiding this comment.
This LOG should be at debug level
| // The SSL context of the coordinator is cached for the JVM, so it should be cleared in between the tests | ||
| FederatedSSLUtil.resetClientContext(); | ||
| FederatedData.resetFederatedSites(); |
There was a problem hiding this comment.
Can we move this code to the setUp method to only have one method that is executed before the tests?
…ederated tutorial with SSL
This PR adds support for reading in a signed certificate and makes the coordinator verify it in place of the existing self-signed certificate generation. To that end, the XML config is extended with the following:
SYSTEMDS_FEDERATED_SSL_KEY_PASSWORDenv varBoth certificate and key are read by each worker from its own config, so they are local per worker. The coordinator has a single trust file, where one CA certificate covers any number of workers, and multiple CAs can be concatenated into one PEM. With hostname verification on, a worker's certificate must be issued for the address the script connects to (
san=dns:..., orsan=ip:...for IP literals), so a certificate valid for one worker cannot be replayed for another.NB: private keys and certificates are added as a part of this PR for SSL-enabled tests to work. They are generated with a dedicated shell script and are irrelevant for anything except the tests.